/**
 * 
 */
package com.antilia.infomaresme.jobs.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.antilia.infomaresme.jobs.IJob;

/**
 * @author Ernesto
 *
 */
public class QuartzJobExecuter implements Job {
	
	public static final String IJob_ID = "__IJob_ID";

	/**
	 * 
	 */
	public QuartzJobExecuter() {
	}
	
	public void execute(JobExecutionContext context) throws JobExecutionException {
		IJob job = (IJob)context.getJobDetail().getJobDataMap().get(IJob_ID);
		if(job == null)
			throw new JobExecutionException("Could not find IJob class");
		try {
			job.execute();
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobExecutionException(e);
		}
	}
}
